import kyo.*;

public class InputTest {
    static public void main(String [] args) {
        Input<Integer> i = new Input<Integer>();

        i.setData(1095);
        i.setRun(new InputRun() {
            public <D> RunState handle(Keysym sym, StringBuilder s, D data) {
                switch (sym) {
                    case UP:
                        System.out.printf("向上走!\n");
                        break;
                    case DOWN:
                        System.out.printf("向下走!\n");
                        break;
                    case LEFT:
                        System.out.printf("向左走!\n");
                        break;
                    case RIGHT:
                        System.out.printf("向右走!\n");
                        break;
                }
                return RunState.RUNNING;
            }
        });

        i.regKey(Keysym.UP, Keysym.LEFT, Keysym.RIGHT);
        i.regKey(Keysym.DOWN);

        i.regKey(Keysym.a, new InputRun() {
            public <D> RunState handle(Keysym sym, StringBuilder s, D data) {
                Vt.cmd(VtCmd.SAVE).gotoxy(15, 1).out("hello world", VtColor.RED);
                System.out.printf("data = %d\n", data);
                Vt.cmd(VtCmd.LOAD);
                return RunState.RUNNING;
            }
        });

        // System.out.println(i.key("请输入一个字符:"));
        String s = i.getLine("请输入一行字符串: ");
        System.out.println(s);

        i.close();
    }
}
